/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller.all;

import dao.DanhmucDAO;
import dao.SanphamDAO;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import pojo.Danhmuc;
import pojo.Sanpham;

/**
 *
 * @author BlueZky
 */
public class trangChuController implements Controller {

    public trangChuController() {
        //Initialize controller properties here or
        //in the Web Application Context

//        setCommandClass(MyCommand.class);
//        setCommandName("MyCommandName");
//        setSuccessView("successView");
//        setFormView("formView");
    }



    @Override
    public ModelAndView handleRequest(HttpServletRequest hsr, HttpServletResponse hsr1)  {

        ModelAndView mv = null;
        List<Sanpham> danhSach = null;
        List<Sanpham> banChay = null;

        danhSach = SanphamDAO.laySanPhamMoiNhat(10);
        banChay = SanphamDAO.laySanPhamBanChayD(10);
        List<Danhmuc> dsdanhmuc = DanhmucDAO.layDanhSach();

        mv = new ModelAndView("All/index");
        mv.addObject("dsdanhmuc", dsdanhmuc);
        mv.addObject("danhSach", danhSach);
        mv.addObject("banChay", banChay);
        return mv;
    }
}
